﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Common;
using KendoMvcUI.Core;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class FlatColorPicker:KendoUIBase
    {
        public FlatColorPicker(KendoUIControlSettings settings,ViewContext context,IViewDataContainer viewDataContainer)
            :base(settings,context,viewDataContainer)
        { }
        public override string RenderHtml()
        {
            return "<div id=\"{0}\"></div>".Formator(Settings.Id);
        }
    }
    public class FlatColorPickerSettings : KendoUIControlSettings
    {
        public FlatColorPickerSettings()
            : base("kendoFlatColorPicker")
        { }
        /// <summary>
        /// default:false
        /// </summary>
        public bool? Opacity { get; set; }
        /// <summary>
        /// default:false
        /// </summary>
        public bool? Buttons { get; set; }
        /// <summary>
        /// default:null
        /// </summary>
        public string Value { get; set; }
        /// <summary>
        /// default:true
        /// </summary>
        public bool? Preview { get; set; }
        /// <summary>
        /// Specifies whether the UI should be updated while the user is 
        /// typing in the input field, whenever a valid color can be parsed. 
        /// If you pass false for this, the widget will update only when ENTER is pressed.
        /// default:true
        /// </summary>
        public bool? Autoupdate { get; set; }
        [PropertySetting(IsIngoreForJavaScript = true)]
        public Action<ColorMessage> Messages { get; set; }
        #region 事件
        public string On_Change { get; set; }
        #endregion
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToJsSettings()
        {
            string jsScript = base.ToJsSettings();
            if (!jsScript.EndsWith(","))
                jsScript += ",";

            if (Messages != null)
            {
                var msg = new ColorMessage();
                Messages(msg);
                jsScript += jsScript + ",";
            }

            return jsScript.TrimEnd(',');
        }
        
    }
}
